home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5135 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: Re: Incrementing enumerated types
  5. Date: 02 Feb 1996 18:29:39 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb2112939@qcd.lanl.gov>
  8. References: <Andy.Law-3101961138310001@pc0734.ri.bbsrc.ac.uk> <4eqoq2$bi5@news.halcyon.com>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: normanb@halcyon.com's message of Thu, 01 Feb 1996 16:13:20 GMT
  13.  
  14. In article <4eqoq2$bi5@news.halcyon.com> normanb@halcyon.com (Norm
  15. Bryar) writes: 
  16. <snip>
  17.    Doubtless not legal because enum values needn't be consecutive.
  18.    enum bleah { error=-1, empty, argle, bargle, targle=4, zargle=8 }.
  19.  
  20.    Use the enum where a programmer must read the code, like in switch
  21.    statements, conditionals, intializations, but cast it to int in the
  22.    for-loop (if you're positive it's values are consecutive, like indices
  23.    into an array).
  24.  
  25. This is one case where the answer differs in C and C++. In C enums can
  26. be freely mixed with ints, and they can be incremented or
  27. decremented. 
  28.  
  29. Cheers
  30. Tanmoy
  31. --
  32. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  33. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  34. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  35. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  36. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  37. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  38.